package com.gk.carshopsys.service;

import com.gk.carshopsys.dao.CarDao;
import com.gk.carshopsys.pojo.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private CarDao carDao;

    @Override
    public int addCarByList(List<Car> list) {
        return carDao.addCarByList(list);
    }

    @Override
    public List<Car> findCar(Car car,String low_price_s,String hight_price_s) {
        Long hight_price=null;
        Long low_price=null;

        if(low_price_s!=null && !low_price_s.equals("")){
            try{
                low_price = Long.valueOf(low_price_s);
            }catch (ClassCastException e){

            }
        }
        if(hight_price_s!=null && !hight_price_s.equals("")){
            try{
                hight_price = Long.valueOf(hight_price_s);
            }catch (ClassCastException e){

            }
        }




        return carDao.findCar(car,low_price,hight_price);
    }

    @Override
    public int addCar(Car car) {
        return carDao.addCar(car);
    }

    @Override
    public int updateCar(Car car) {
        return carDao.updateCar(car);
    }

    @Override
    public int delCar(List<Integer> car) {
        return carDao.delCar(car);
    }
}
